<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
    <script src="./untils/flexible.js"></script>
    <link rel="stylesheet" href="./css/base.css">
    <link rel="stylesheet" href="./css/index.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
    <div class="header">
        <img class="logo" src="./assets/images/header_logo.png" alt="">
        <img class="app" src="./assets/images/header_app.png" alt="">
    </div>
    <div class="search">
        <input type="text" placeholder="请输入你想比价的商品">
        <button>搜索</button>
    </div>
    
    <div class="nav">

    </div>
    
    <p class="midP">超值折扣推荐</p>
    <ul class="product">
        
    </ul>
    
    <div class="foot">
        <div class="more">
            <a href="#">更多优惠信息>></a>
        </div>
        <div class="brand">
            <p>品牌排行</p>
        </div>
        <ul>
            <li>登入</li>
            <li>注册</li>
            <li class="goTop">返回顶部</li>
        </ul>
        
        <p id="p1"><span class="span1">手机APP下载 </span> 慢慢买手机版 <span class="span2">--掌上比价平台</span></p>
        <p id="p2">m.manmanbuy.com</p>
    </div>
</body>
<script>
    $(window).scroll(function(){
        let scrollTop=$(window).scrollTop();
    })
    $(".goTop").on("click",function(){
        $("html").animate({
            scrollTop:0
        },100)
    })
</script>
<script>
        
    $.ajax({
        url:"http://chst.vip:1234/api/getmoneyctrl",
        type:"get"
    }).then(res=>{
        let{ a, b,result}=res;
        let htmlCon="";
        for(var i=0; i<result.length; i++){
            htmlCon+=`
            <li productid=${result[i].productId}>
                ${result[i].productImgSm}
                <p>${result[i].productName}<span>${result[i].productPinkage}</span></p>
                <span id="outSpan">${result[i].productFrom}|${result[i].productTime} <span>${result[i].productComCount}</span></span>
            </li>
            `    
        }
        $(".product").html(htmlCon);
        $(".product").on("click","li",function(){
            let productid=$(this).attr("productid");
            location.href=`./pages/detail.html?productid=${productid}`
        })
    })
</script>
<script>
    let html="";
    $.ajax({
        url: "http://chst.vip:1234/api/getindexmenu",
        type: "get"
    }).then(res=>{
        let {result}=res;
        for(var i=0; i<result.length; i++){
            result[i].img=result[i].img.replace(/[\"].+?[\/]/, "\"./assets/images/");
            html+=`
                <div class="item">
                    ${result[i].img}
                    <p class="pp">${result[i].name}</p>
                </div>
            `
        }
        $(".nav").html(html);
        $(".nav .item").eq(7).click(function(){
            $(".nav").css("height","8rem");
        })
    }).catch(err=>{
        console.log(err);
    })
    
</script>
</html>